package com.fho4565.core.cdgroup;

import java.io.Serial;
import java.util.HashSet;

public class CommandGroupList extends HashSet<CommandGroup> implements Cloneable {

    @Serial
    private static final long serialVersionUID = -1964501927501089044L;

    public CommandGroupList() {
        super();
    }
    public CommandGroup getByName(String name){
        return this.stream().filter(commandGroup -> commandGroup.getName().equals(name)).findFirst().orElse(null);
    }
    public boolean contains(String name){
        return this.stream().anyMatch(commandGroup -> commandGroup.getName().equals(name));
    }
    @Override
    public Object clone() {
        CommandGroupList result;
        result = (CommandGroupList)super.clone();
        result.clear();
        result.addAll(this);
        return result;
    }
}
